#include "GameObject.h"

//-- Game object class used to get and set basic properties of 
//-- all game objects 

//-- Initialise the velocity
GameObject::GameObject(): mVelocity(2.5f, 0.0f, 0.0f) {
	
};

GameObject::~GameObject(){};

void GameObject::Init(abfw::Mesh* mesh)
{
	mInstance.set_mesh(mesh);
	mLocalTransform.SetIdentity();
	mTranslation.SetIdentity();
}

void GameObject::SetVelocity(abfw::Vector3 velocity)
{
	mVelocity = velocity;
}

abfw::Vector3 GameObject::GetVelocity()
{
		return mVelocity;
}

abfw::Model* GameObject::GetModel()
{
	return &mModel;
}

abfw::Matrix44* GameObject::GetLocalTransform()
{
	return &mLocalTransform;
}

//-- moves the gameobject by the specified velocity
void GameObject::Move()
{
	mLocalTransform.SetTranslation(abfw::Vector3(mLocalTransform.GetTranslation()  + mVelocity));
}

void GameObject::SetOrigin(abfw::Matrix44 origin)
{
	mOrigin = origin;
}
abfw::Matrix44 GameObject::GetOrigin()
{
	return mOrigin;
}

void GameObject::SetLocalScale(abfw::Vector3 scale)
{
	mScale.Scale(scale);
}
abfw::Matrix44 GameObject::GetLocalScale()
{
	return mScale;
}

void GameObject::SetLocalTranslation(abfw::Vector3 translate)
{
	mTranslation.SetTranslation(translate);
}

abfw::Matrix44 GameObject::GetLocalTranslation()
{
	return mTranslation;
}


void GameObject::SetLocalRotationX(float x)
{
	mRotationX.RotationX(x);
}

void GameObject::SetLocalRotationY(float y)
{
	mRotationY.RotationY(y);
}

void GameObject::SetLocalRotationZ(float z)
{
	mRotationZ.RotationZ(z);
}


abfw::MeshInstance GameObject::GetMeshInstance()
{
	return mInstance;

}

void GameObject::SetTransform(abfw::Matrix44 transform)
{
	
	mInstance.set_transform(transform);
}


abfw::Matrix44 GameObject::GetLocalRotation()
{
	abfw::Matrix44 finalRotation;

	finalRotation = mRotationX * mRotationY * mRotationZ;

	return finalRotation;
}